<template>
	<view>
		<u-tabbar :value="value" @change="change" :fixed="true" :placeholder="true" :safeAreaInsetBottom="true">
			<u-tabbar-item v-for="item in list" :text="item.text" :icon="item.icon"></u-tabbar-item>

		</u-tabbar>
	</view>
</template>


<script>
	export default {
		name: "tabbar",
		data() {
			return {
				value: "0",
			};
		},
		computed: {

			list() {
				let v = this.value;
				let r = [{
						text: "消息",
						page: "/pagesmessage/index/index",
						icon: "chat"
					},
					{
						text: "工作台",
						page: "/pageswork/index/index",
						icon: "grid"
					},
					{
						text: "我的",
						page: "/pageshome/index/index",
						icon: "home"
					}
				]
				return r;
			},

		},

		module() {

		},
		mounted() {
			this.init()

		},
		// ready
		methods: {
			init() {
				let pages = getCurrentPages();
				console.log(pages);
				let fullPath = pages[pages.length - 1].$page.fullPath
				let i = this.list.findIndex(e => {
					return fullPath.includes(e.page)
				})
				this.value = String(i)
			},
			change(item) {
				// this.value = item
				let dqitem = this.list[item]
				uni.reLaunch({
					url: dqitem.page
				})
				console.log(item, this.value);
			}
		}
	}
</script>

<style></style>